package com.bysj.yqsht.web.controller;

import com.bysj.yqsht.bean.CheckallStudent;
import com.bysj.yqsht.bean.CheckallTeacher;
import com.bysj.yqsht.bean.extend.CheckallStudentExtend;
import com.bysj.yqsht.service.ICheckallStudentService;
import com.bysj.yqsht.utils.Message;
import com.bysj.yqsht.utils.MessageUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/checkallStudent")
@Api(description = "学生考勤总记录")
public class CheckallStudentController {
    @Autowired
    private ICheckallStudentService checkallStudentService;

    @GetMapping("findAll")
    public Message findAll(){
        List<CheckallStudent> list = checkallStudentService.findAll();
        return MessageUtil.success(list);
    }
    @GetMapping("findWithAll")
    public Message findWithAll(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int limit){
        List<CheckallStudentExtend> list = checkallStudentService.findWithAll(pageNum,limit);
        return MessageUtil.success(list);
    }
    @GetMapping("findWithAllBy")
    public Message findWithAllBy(Long studentId,Long classesId){
        List<CheckallStudentExtend> list = checkallStudentService.findWithAllBy(studentId, classesId);
        return MessageUtil.success(list);
    }
    @GetMapping("deleteById")
    public Message deleteById(Long id){
        checkallStudentService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(CheckallStudent checkallStudent){
        checkallStudentService.saveOrUpdate(checkallStudent);
        return MessageUtil.success("修改或新增成功");
    }
}
